package com.bowen.demo.demo002;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <h3>java-study</h3>
 * <p>CarCovertBasic转换接口</p>
 * @author : zhang.bw
 * @date : 2020-10-27 16:53
 **/
@Mapper
public interface CarCovertBasic {
	CarCovertBasic INSTANCE = Mappers.getMapper(CarCovertBasic.class);

	/**
	 * 属性一致
	 * @param source
	 * @return
	 */
	//CarVo toConvertVo1(CarPo source);

	/**
	 * 属性名称不一致
	 * @param source
	 * @return
	 */
	/*@Mapping(source = "carName", target = "name")
	CarVo toConvertVo2(CarPo source);*/

	/**
	 * 集合类型转换
	 * @param source
	 * @return
	 */
	/*@Mapping(source = "carName", target = "name")
	CarVo toConvertVo(CarPo source);

	List<CarVo> toConvertVos(List<CarPo> source);*/


	/**
	 * 集合类型转换，属性类型不一致
	 */
	/*@Mappings({
		@Mapping(source = "carName", target = "name"),
		@Mapping(source = "createTime", target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
	})
	CarVo toConvertVo(CarPo source);

	List<CarVo> toConvertVos(List<CarPo> source);*/


	/**
	 * 多对一映射
	 * @param source
	 * @return
	 */
	@Mappings({
			@Mapping(source = "carName", target = "name"),
			@Mapping(source = "createTime", target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss"),
	})

	CarVo toConvertVo(CarPo source);
	List<CarVo> toConvertVos(List<CarPo> source);
	CarBo toConvertBo(CarPo source1, AttributePo source2);
}
